package com.geostar.constructionland.common.dao.impl;

import com.geostar.constructionland.common.dao.YzGeoJsonDao;
import com.geostar.constructionland.common.entity.logs.mongolog.YzGeoJson;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;

@Component
public class YzGeoJsonDaoImpl implements YzGeoJsonDao {
    @Autowired
    MongoTemplate mongoTemplate;

    @Override
    public void saveYzGeoJson(YzGeoJson yzGeoJson) {
        mongoTemplate.save(yzGeoJson);
    }

    @Override
    public YzGeoJson queryYzGeoJson(String yeGeoJsonId) {
        if(StringUtils.isNotBlank(yeGeoJsonId)){
            Query query = new Query().addCriteria(Criteria.where("id").is(yeGeoJsonId));
            return mongoTemplate.findOne(query, YzGeoJson.class);
        }
        return null;
    }
}
